home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 4.7 KB | 173 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWLinShp.h
- // Release Version: $ 1.0d1 $
- //
- // Creation Date: 3/28/94
- //
- // Copyright: © 1993, 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWLINSHP_H
- #define FWLINSHP_H
-
- #ifndef FWSHAPE_H
- #include "FWShape.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- #ifndef FWINK_H
- #include "FWInk.h"
- #endif
-
- #ifndef FWSTYLE_H
- #include "FWStyle.h"
- #endif
-
- //==============================================================================
- // •• Forward Declarations
- //==============================================================================
-
- class FW_CGraphicContext;
- class XMPTransform;
- class FW_CLineShapeRep;
- class FW_COvalShape;
- class FW_CRoundRectShape;
- class FW_CArcShape;
- class FW_CRectShape;
- class FW_CRegionShape;
-
- //==============================================================================
- // •• CLASS FW_CLineShape
- //==============================================================================
-
- class FW_CLineShape : public FW_CShape
- {
- //------------------------------------------------------------------------------
- // • Constructors
- //
- public:
- FW_CLineShape();
- FW_CLineShape(const FW_CPoint& start, const FW_CPoint& end);
-
- FW_CLineShape(const FW_CLineShape& other);
- FW_CLineShape(FW_CLineShapeRep* rep);
-
- //-------------------------------------------------------------------------------
- // • Operators
- //
- public:
- FW_CLineShape& operator=(const FW_CLineShape& other);
- FW_CLineShape& operator=(FW_CLineShapeRep* other);
- FW_CLineShapeRep* operator->() const
- {return (FW_CLineShapeRep*)GetRep();}
-
- //----------------------------------------------------------------------------------------
- // • Conversion
- //
- public:
- operator FW_COvalShape() const;
- operator FW_CRoundRectShape() const;
- operator FW_CArcShape() const;
- operator FW_CRectShape() const;
- operator FW_CRegionShape() const;
-
- //------------------------------------------------------------------------------
- // • Static Methods
- //
- public:
- static void DrawLine(FW_CGraphicContext* graphicContext,
- const FW_CPoint& start,
- const FW_CPoint& end);
- };
-
- //==============================================================================
- // •• class FW_CLineShapeRep
- //==============================================================================
-
- class FW_CLineShapeRep : public FW_CShapeRep
- {
- friend class FW_CLineShape;
-
- //------------------------------------------------------------------------------
- // • Constructors/Destructors
- //
- protected:
- FW_CLineShapeRep();
- FW_CLineShapeRep(const FW_CPoint& start, const FW_CPoint& end);
-
- virtual ~FW_CLineShapeRep();
-
- //------------------------------------------------------------------------------
- // • Inherited API
- //
- public:
- // ----- Rendering -----
- virtual void Draw(FW_CGraphicContext* graphicContext);
- static void DrawLine(FW_CGraphicContext* graphicContext,
- const FW_CPoint& start,
- const FW_CPoint& end);
-
- // ----- Hit Testing -----
- virtual FW_HitTestPart HitTest(const FW_CPoint& test) const;
-
- // ----- Transform -----
- virtual void Transform(XMPTransform* transform);
- virtual void InverseTransform(XMPTransform* transform);
-
- virtual void MoveShape(XMPCoordinate deltaX, XMPCoordinate deltaY);
- virtual void MoveShapeTo(XMPCoordinate x, XMPCoordinate y);
-
- // ----- Geometry -----
- virtual FW_CRect GetShapeBounds() const;
-
- // ----- Default shape -----
- virtual void SetAsDefault() const;
-
- // ----- Stream -----
- virtual void Flatten(FW_CWritableStream& stream);
- virtual void Unflatten(FW_CReadableStream& stream);
-
- //------------------------------------------------------------------------------
- // • New API
- //
- public:
- FW_CLineShape Copy() const;
-
- FW_CPoint GetLineStart() const
- {return fStart;}
- FW_CPoint GetLineEnd() const
- {return fEnd;}
-
- void SetLineStart(const FW_CPoint& start)
- {fStart = start; Changed();}
- void SetLineEnd(const FW_CPoint& end)
- {fEnd = end; Changed();}
-
- //------------------------------------------------------------------------------
- // • Data Members
- //
- private:
- FW_CPoint fStart;
- FW_CPoint fEnd;
- };
-
- //==============================================================================
- // •• Inlines
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // • FW_CLineShape::DrawLine
- //------------------------------------------------------------------------------
- inline static void FW_CLineShape::DrawLine(FW_CGraphicContext* graphicContext,
- const FW_CPoint& start,
- const FW_CPoint& end)
- {
- FW_CLineShapeRep::DrawLine(graphicContext, start, end);
- }
-
- #endif